﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class quantri_Login : System.Web.UI.Page
{
    DataClassesDataContext db = new DataClassesDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_login_Click(object sender, EventArgs e)
    {
        var account = from a in db.Accounts where a.Acc_username == txtUsername.Text select a  ;

        if (account.Count() > 0)
        {
            var user = account.FirstOrDefault();
            if (txtPassword.Text == user.Acc_password.Trim() )
            {
                Session["Username"] = txtUsername.Text.Trim();
                Response.Redirect("Default.aspx");
            }
            else
            {
                Response.Write("<Script> alert('Sai mật khẩu, vui lòng nhập lại.') </Script>");
            }
        }
        else
        {
            Response.Write("<Script> alert('Không tìm thấy tài khoản, vui lòng nhập lại.') </Script>");
        }
      
    }
}
